/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 导入状态
 *
 * @author hxloongs
 * @date 2024-8-19
 */
@AllArgsConstructor
@Getter
public enum ImportResultStatusEnum {
    UPDATED_IMPORT(1, "修改后导入"),
    IMPORT_SUCCESS(2, "导入成功"),
    NOT_IMPORT(3, "未导入"),
    IMPORT_FAIL(4, "导入失败");
    private final Integer value;
    private final String desc;

    public static String getDescByValue(Integer value) {
        ImportResultStatusEnum importResultStatusEnum = forValue(value);
        if (importResultStatusEnum == null) {
            return null;
        }
        return importResultStatusEnum.getDesc();
    }

    public static ImportResultStatusEnum forValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (ImportResultStatusEnum importResultStatusEnum : ImportResultStatusEnum.values()) {
            if (importResultStatusEnum.getValue().equals(value)) {
                return importResultStatusEnum;
            }
        }
        return null;
    }

    public static ImportResultStatusEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (ImportResultStatusEnum importResultStatusEnum : ImportResultStatusEnum.values()) {
            if (desc.equals(importResultStatusEnum.getDesc())) {
                return importResultStatusEnum;
            }
        }
        return null;
    }
}
